home *** CD-ROM | disk | FTP | other *** search
- /*
-
- The following source text is provided for the benefit of customers of
- Aladdin Systems, Inc., who wish to create custom Product Installers that
- incorporate functions similar to, but not exactly the same as, the undoFolder
- code resource that we supply on the StuffIt Installer Licensee disk.
-
- If you are a licensee of our installation products, you may call Aladdin for technical
- support with this source code. Please contact Aladdin Developer Technical Support
- at (408) 761-6200. To license Aladdin installation technology, please contact
- Developer Product Licensing at the same telephone number. Or you can FAX us at
- (408) 761-6206.
-
- */
-
- #include <MacHeaders>
-
-
- // IEnd.c By Raymond Lau.
- //
- // Copyright © 1992-93 Aladdin Systems, Inc. & Raymond Lau.
- // All Rights Reserved.
- //
- // This source text produces an IEnd code-resource, which can
- // be called by a Product Installer at the end of the installation
- // process. Specifications for IBeg, IMid, and IEnd code resources
- // are given in the documentation for the StuffIt Installer™.
- //
- // This subroutine performs the following functions:
- //
- // • Move everything within the user-specified destination folder
- // into the parent of that folder (i.e., one level up).
- // • If an item cannot be moved to the parent directory because
- // another item there already has the same name, then rename the
- // item to be moved, before actually moving it.
- // • Finally, delete the emptied user-specified folder.
- //
- // CHANGE HISTORY:
- //
- // VER DATE ENGR DESCRIPTION
- // 1 93.04.14 rl Initial version, some commentary added
- // by Jim Merritt (jam).
- // 2 94.03.14 jam Modified main to observe new packages
- // parameter.
- //
- // 3 94.05.05 rmt Rendered into ANSI C for Symantec C 6.0
- // by Robert Thorne (rmt)
- //
- //
- //
- //
-
- typedef unsigned char uchar;
-
- // Function Prototype
- uchar *pstrcat (uchar *s1, uchar *s2) ;
-
-
- /*
- Concatenate the pascal string "s2" onto the end of the current
- contents of the pascal string "s1". Returns "s1".
- */
-
-
- uchar *pstrcat (uchar *s1, uchar *s2)
- {
- short i;
-
- for (i = 1; i <= s2 [0]; ++i)
- s1 [++s1 [0]] = s2 [i];
-
- return (s1);
- }
-
-
- pascal short main(short abort,short vol,long dir,uchar *name,
- unsigned short packages)
-
- { if(!abort) {
- HParamBlockRec HRec;
-
- HRec.ioParam.ioNamePtr = (StringPtr)name;
- HRec.ioParam.ioVRefNum = vol;
- HRec.fileParam.ioDirID = dir;
- HRec.fileParam.ioFDirIndex = 0;
-
- if(PBGetCatInfoSync((CInfoPBPtr)&HRec)) {
- // really weird! Nothing got unstuffed?
- abort = TRUE;
- } else {
- long sourcedir = HRec.fileParam.ioDirID;
- short i;
-
- if(!(HRec.fileParam.ioFlAttrib & 0x10))
- goto out;
-
- i = 1;
- for(;;) {
- short j;
- uchar str[10],newname[32],sourcename[32];
- CMovePBRec cmpb;
-
- HRec.fileParam.ioFDirIndex = 1;
- HRec.fileParam.ioDirID = sourcedir;
- HRec.fileParam.ioVRefNum = vol;
- HRec.fileParam.ioNamePtr = sourcename;
-
- if(PBGetCatInfoSync((CInfoPBPtr)&HRec))
- break;
-
- j = 0;
-
- for(;;) {
- // see if it exists in the level above.
- BlockMove(sourcename,newname,32);
- if(j) {
- if(newname[0] > 28)
- newname[0] = 28;
- NumToString(j,str);
- pstrcat(newname,"\p.");
- pstrcat(newname,str);
- }
- HRec.fileParam.ioFDirIndex = 0;
- HRec.fileParam.ioDirID = dir;
- HRec.fileParam.ioVRefNum = vol;
- HRec.fileParam.ioNamePtr = newname;
-
- if(PBGetCatInfoSync((CInfoPBPtr)&HRec) == fnfErr) {
- if(!j)
- break;
-
- // hrumph -- check current level as well.
- HRec.fileParam.ioFDirIndex = 0;
- HRec.fileParam.ioDirID = sourcedir;
- HRec.fileParam.ioVRefNum = vol;
- HRec.fileParam.ioNamePtr = newname;
-
- if(PBGetCatInfoSync((CInfoPBPtr)&HRec) == fnfErr)
- break;
- }
-
- j++;
- }
-
- if(j) {
- HRec.fileParam.ioDirID = sourcedir;
- HRec.fileParam.ioVRefNum = vol;
- HRec.fileParam.ioNamePtr = (StringPtr)sourcename;
- HRec.ioParam.ioMisc = (Ptr)newname;
- PBHRenameSync(&HRec);
- }
-
- cmpb.ioNamePtr = (StringPtr)newname;
- cmpb.ioVRefNum = vol;
- cmpb.ioNewName = (StringPtr)0L;
- cmpb.ioNewDirID = dir;
- cmpb.ioDirID = sourcedir;
-
- PBCatMoveSync(&cmpb);
- }
-
- // now delete the folder
- HRec.ioParam.ioNamePtr = (StringPtr)name;
- HRec.ioParam.ioVRefNum = vol;
- HRec.fileParam.ioDirID = dir;
- PBHDeleteSync(&HRec);
- }
- }
-
- out:
- return abort;
- }
-